#include "stdio.h"
void exchange(int a[],int n);
main()
{	 	 	 	  		 
    int i;
    int a[10];

    printf("Input 10 numbers:\n");
    for(i=0;i<10;i++)
    {	 	 	 	  		 
	scanf("%d",&a[i]);//2
    }

    exchange(a,10);//2

    printf("After exchange:\n");
    for(i=0;i<10;i++)
    {	 	 	 	  		 
	printf("%4d",a[i]);//2
    }

}	 	 	 	  		 
void exchange(int a[],int n)//2
{	 	 	 	  		 
   int max,min,p,q;
   int i,term;

   max=min=a[0];//1
   p=q=0;//1
  
   for(i=1;i<n;i++)//1
   {	 	 	 	  		 
	if(a[i]>max)//1
        {	 	 	 	  		 
	    max=a[i];//1
            p=i;//1
	}
        else if(a[i]<min)//1
        {	 	 	 	  		 
	    min=a[i];//1
            q=i;//1
	}
   }

   term=a[p];//1
   a[p]=a[q];//1
   a[q]=term;//1
}